<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="帮手" prop="bsId">
        <el-input
            v-model="queryParams.bsId"
            placeholder="请输入帮手姓名"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="家长" prop="wxId">
        <el-input
            v-model="queryParams.wxId"
            placeholder="请输入家长姓名"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单号" prop="orderId">
        <el-input
            v-model="queryParams.orderId"
            placeholder="请输入订单号"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" style="width: 308px;">
        <el-date-picker
            v-model="dateRange"
            value-format="YYYY-MM-DD"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="evalList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="订单号" align="center" prop="orderId" />
      <el-table-column label="家长" align="center" prop="jzName" />
      <el-table-column label="帮手" align="center" prop="bsName" />
      <el-table-column label="星级" align="center" prop="star">
        <template #default="scope">
          <el-rate
              v-model="scope.row.star"
              disabled
              text-color="#ff9900"
          />
        </template>
      </el-table-column>
      <el-table-column label="评价内容" align="center" prop="content" />
      <el-table-column label="评价时间" align="center" prop="addtime" />
<!--      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!--        <template #default="scope">-->
<!--          <el-button link type="primary" @click="handleDetail(scope.row)" v-hasPermi="['by:eval:detail']">详情</el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />
  </div>
</template>
<script setup>
import { listEval, getEval } from "@/api/bydll/eval";

const {proxy} = getCurrentInstance();
const {sys_normal_disable} = proxy.useDict("sys_normal_disable");
const dateRange = ref([]);
// 遮罩层
const loading = ref(true);
// 选中数组
const ids = ref([]);
// 非单个禁用
const single = ref(true);
// 非多个禁用
const multiple = ref(true);
// 显示搜索条件
const showSearch = ref(true);
// 总条数
const total = ref(0);
// 订单评价表格数据
const evalList = ref([]);
// 弹出层标题
const title = ref("");
// 是否显示弹出层
const open = ref(false);

const data = reactive({
  // 查询参数
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    orderId: null,
    wxId: null,
    bsId: null,
    star: null,
    content: null,
    addtime: null,
    showflag: null
  },
  // 表单参数
  form: {},
// 表单校验
  rules: {}
});

const {queryParams, form, rules} = toRefs(data);

/** 查询订单评价列表 */
function getList() {
  loading.value = true;
  listEval(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => {
    evalList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}
// 取消按钮
function cancel() {
  open.value = false;
  reset();
}
// 表单重置
function reset() {
  form.value = {
    id: null,
    orderId: null,
    wxId: null,
    bsId: null,
    star: null,
    content: null,
    addtime: null,
    showflag: null
  };
  resetForm("form");
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  dateRange.value = [];
  resetForm("queryForm");
  handleQuery();
}
/** 详情按钮操作 */
function handleDetail() {
  reset();
  open.value = true;
  title.value = "评价详情";
}
getList();
</script>

